<?php
$curl = curl_init();
$url = "https://www.17k.com/all";
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($curl,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
$data = curl_exec($curl);
//print_r($data);

$pre = '#<tr class="bg0">.*<td class="td2">.*<a href=".*" target="_blank">(.*)</a>.*<td class="td4">.*<a href=".*" target="_blank">(.*)</a>.*<td class="td6">.*<a href=".*" target="_blank".*title=".*">(.*)</a>.*<td class="td7">(.*)</td>.*</td>.*</td>.*</td>.*</td>.*</a>.*</td>.*</tr>.*#isU';
preg_match_all($pre,$data,$reslut);

$type = $reslut[1];
$conent = $reslut[2];
$author = $reslut[3];
$time = $reslut[4];
$dbh = new PDO('mysql:host=localhost;dbname=1705php', "root", "root");
$sql = "insert into `book`";
foreach($type as $key=>$value)
{
    $sql.="('null','$type[$key]','$conent[$key]','$author[$key]','$time[$key]')values,";
}
$sql = substr($sql,0,-1);
print_r($sql);

?>
